package com.ihteima.mapper;

import com.ihteima.model.vo.UpdateUserInfoDO;
import com.ihteima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * ClassName: UserMapper
 * Package: com.ihteima.mapper
 * Description:
 *
 * @Auther gongkaiming
 * @Create 2025/10/26 17:47
 * @Version 1.0
 */
@Mapper
public interface UserMapper {
    
    @Select("select * from user where username = #{username}")
    User findByName(String username);
    
    @Insert("insert into user (username, password, create_time, update_time) values (#{username}, #{password}, now(), now())")
    int insert(String username, String password);

    @Select("select * from user where id = #{id}")
    User findById(Long id);

    /**
     * 更新用户信息
     * @param updateUserInfoDO
     * @return
     */
    int updateUserInfo(UpdateUserInfoDO updateUserInfoDO);
    
    @Update("update user set password = #{password} where id = #{id}")
    int updatePassword(Long id, String password);
}
